package com.nondo.rdp.finance.repository.circle;

import com.nondo.rdp.core.common.StatusConstant;
import com.nondo.rdp.finance.domain.circle.Circle;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.Optional;

public interface CircleRepository extends JpaRepository<Circle, Long>, JpaSpecificationExecutor<Circle> {
    @Query("select c from Circle c where c.id=:id and delFlag = '" + StatusConstant.DEL_FLAG_NORMAL + "'")
    Optional<Circle> findOne(@Param("id") int id);

    @Modifying
    @Query("update Circle set delFlag='" + StatusConstant.DEL_FLAG_DELETE + "' where id = ?1")
    void deleteById(Long id);

    Circle save(Circle activity);
}
